package net.neptech.controller;

import jakarta.annotation.Nullable;
import net.neptech.bo.PatientBo;
import net.neptech.feign.AppointmentFeign;
import net.neptech.model.appointment.MedicalCase;
import net.neptech.model.sys.Patient;
import net.neptech.service.PatientService;
import net.neptech.vm.ResponseResult;
import net.neptech.vo.PatientVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/system/patient")
public class PatientController {

    /**
     * 功能描述: 根据userId查询病人信息
     *
     * @param:
     **/
    @Autowired
    private PatientService patientService;
    @Autowired
    private AppointmentFeign appointmentFeign;

    @GetMapping("/getPatientByUserId/{userId}")
    public ResponseResult<List<Patient>> getPatientByUserId(@PathVariable("userId") Long userId) {
        return patientService.getPatientByUserId(userId);
    }

    /**
     * 获取就诊人列表
     */
    @PostMapping("/list")
    public ResponseResult<List<PatientVo>> list(@RequestBody @Nullable PatientBo patientBo) {
        System.out.println(patientBo);
        //根据科室id获取病人列表
        List<MedicalCase> medicalCaseList = appointmentFeign.medicalCaseList(patientBo.getDeptIds()).getData();
        //获取病人详细信息
        List<PatientVo> patientList = patientService.getPatientByPatientIds(medicalCaseList);
        return ResponseResult.success(patientList);
    }
}
